﻿using System;
using System.Text;
using System.Web;
using Clipping.Infrastructure.Interfaces;

namespace Clipping.SearchUrlConstructors
{
	public class BaiduWebUrlConstructor : ISearchUrlConstruct
	{
		private Encoding _urlEncoding = Encoding.GetEncoding("gb2312");
		public Uri ConstructUrl(Infrastructure.Models.SearchObject searchObj)
		{
			//Contract.Requires(searchObj != null);
			return new Uri(string.Format("http://www.baidu.com/s?wd={0}", HttpUtility.UrlEncode(searchObj.Keyword, this._urlEncoding)));
		}

		public Uri ConstructAbsoluteUrl(Uri baseUri, string url)
		{
			return UriHelper.ConstructAbsoluteUrl(baseUri, url);
		}
	}
}
